﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="shortcut icon" href="http://master.yunspace.com.cn/favicon.ico">
    <title>YUNSPACE | 场地大师</title>
    <style>
        .error-block {
            text-align: left;
            margin-left: 85px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="~/Content/css/382.css">
    <link rel="stylesheet" href="~/Content/css/style.3.2.0.css">
    <link href="~/Content/css/framework-ui.css" rel="stylesheet" />
    <script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
    <script src="~/Content/js/layer-v3.1.1/layer/layer.js"></script>
    
    
    
</head>



<body>
    <div class="wrapper">

        <header class="page-header">
            <nav class="navbar mega-menu" role="navigation">
                <div class="container-fluid">
                    <div class="clearfix navbar-fixed-top">
                        <div class="cover none"></div>
                        <a id="index" class="page-logo" href="/Login/Login">
                            <img src="~/Content/img/logo_new_0427.png" alt="Logo">
                        </a>
                    </div>

                </div>
            </nav>
        </header>

        <div class="container-fluid" id="container">
            <div class="cover none"></div>
            <div class="page-content page-reg-custom">
                <div class="portlet">
                    <div class="portlet-title">
                        <strong>注册创建场地</strong>
                    </div>
                    <div class="person_content clearfix">
                        <div class="col-md-6 person_left">
                            <div class="form-group form-md-line-input ">
                                <label class="fl" for="form_control_1">公司名称</label>
                                <input type="text" class="fl form-control" id="name" value="" placeholder="请输入公司名称">
                                <label></label>
                            </div>
                            <div class="form-group form-md-line-input ">
                                <label class="fl" for="form_control_1">联系人</label>
                                <input type="text" class="fl form-control " id="contact" value="" placeholder="请输入联系人">
                                <label></label>
                            </div>
                            <div class="form-group form-md-line-input ">
                                <label class="fl" for="form_control_1">上传营业执照</label>
                                <input id="BusinessLicense" style="width: 73%;display: inline-block;" accept="image/*" class="form-control" type="file" name="filesf" />
                                <input id="F_FilesBtn" onclick="uploadSend('BusinessLicense','BusinessLicense')" type="button" value="上传图片" class="btn btn-primary" />
                            </div>
                            <div class="form-group form-md-line-input ">
                                <label class="fl" for="form_control_1">上传名片</label>
                                <input id="Vcard" accept="image/*" style="width: 73%;display: inline-block;" class="form-control" type="file" name="filesf" />
                                <input id="" onclick="uploadSend('Vcard','Vcard')" type="button" value="上传图片" class="btn btn-primary" />
                            </div>
                          
                            <div class="form-group form-md-line-input ">
                                <label class="fl" for="form_control_1">手机号码</label>
                                <input type="text" class="fl form-control phone" id="phone" value="" placeholder="请输入手机号码">
                                <label></label>
                            </div>
                            <div class="form-group form-md-line-input ">
                                <label class="fl" for="form_control_1">短信验证码</label>
                                <input type="text" class="fl form-control code" id="code" value="" placeholder="请输入验证码">

                                <button class="send-code-btn btn blue btn-lg send_code" id="sendcode">获取短信验证码</button>
                                <label></label>
                            </div>

                            <p class="display-hide error-block"><span class="login_error_msg"></span></p>
                            <button class="btn blue btn-250 next_submit" id="submit">注册</button>
                            <p>已有账号？<a href="/Login/Login">登录</a></p>
                        </div>
                        <div class="col-md-6 person_right hidden-xs">
                            <img src="~/Images/reg.jpg">
                        </div>
                    </div>
                </div>
            </div>
            <p class="copyright">
                2018 © YUNSPACE
                <a href="/Login/Login" title="" target="_blank">Purchase Metronic!</a>
            </p>
        </div>
    </div>
  
    <script>
        $(function () {
            $('#sendcode').click(function () {
                var obj = this;
                var Phone = $('#phone').val();
                if (Phone) {
                    $.ajax({
                        url: "/Login/SendRegisterCode",
                        data: { "Phone": Phone },
                        type: "post",
                        dataType: "json",
                        asyn: false,
                        success: function (data) {
                            if (data.state == "success") {
                                console.log(data.message);
                                settime(obj);
                            }
                        }
                    });
                }
            });

            $('#submit').click(function () {
                var Phone = $('#phone').val();
                var Code = $('#code').val();
                var name = $('#name').val();
                var contact = $('#contact').val();
                if (Phone && Code && name && contact) {
                    if (!VCardfiles.F_path) {
                        $.modalAlert('未上传营业执照', "warning");
                        return false;
                    }
                    if (!BLfiles.F_path) {
                        $.modalAlert('未上传名片', "warning");
                        return false;
                    }

                    $("#submit").attr('disabled', 'disabled').find('span').html("loading...");
                    $.ajax({
                        url: "/Login/RegisterUser",
                        data: { "Phone": Phone, "Code": Code, "Name": name, "Contact": contact, Vcard: VCardfiles.F_path, BL: BLfiles.F_path },
                        type: "post",
                        dataType: "json",
                        asyn: false,
                        success: function (data) {
                            if (data.state == "success") {
                                $.modalAlert("注册成功请登录");
                                $("#submit").find('span').html("注册成功，正在跳转...");
                                window.setTimeout(function () {
                                    window.location.href = "/Login/Login";
                                }, 500);
                            } else {
                                $("#submit").removeAttr('disabled').find('span').html("注册");
                                $.modalAlert(data.message);
                            }
                        }
                    });
                } else {
                    $.modalAlert('信息不能为空', "warning");
                }
            });
        });

        var countdown = 60;

        function settime(obj) {
            if (countdown == 0) {
                obj.removeAttribute("disabled");
                obj.innerText = "获取短信验证码";
                countdown = 60;
                return;
            } else {
                obj.setAttribute("disabled", true);
                obj.innerText = "重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function () {
                settime(obj)
            }, 1000);
        }

        formMessage = function (msg) {
            $('.login_tips').find('.tips_msg').remove();
            $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
        }
        var VCardfiles = {}, BLfiles = {};
        var myDate = new Date();
        var mytime = myDate.getFullYear().toString() + myDate.getMonth().toString() + myDate.getDate().toString();

        function uploadSend(actionId, type) {
            cvalue = "";
            bigvlue = "";
            imgWidthType = "";
            var big = 30;

            var data = new FormData();
            var item = document.getElementById(actionId);
            if (item != null && item.files.length > 0) {
                var files = item.files;
                var fid = files.length;
                bigvlue = "";
                for (var i = 0; i < files.length; i++) {
                    var file = item.files[i];
                    fileSize = file.size;
                    fileSize = Math.round(fileSize / 1024 * 100) / 100; //kb
                    if (fileSize > 30720) {
                        bigvlue += file.name + ' ';
                    } else {
                        data.append(file.name, file);
                        if (type == "Vcard") {
                            VCardfiles = {
                                name: file.name,
                                F_Id: fid + i,
                                tag: '',
                                is_cover: false,
                                photoable_type: type,
                                F_path: 'uploads/files/path/' + mytime + '/' + file.name
                            }
                        }
                        else {
                            BLfiles = {
                                name: file.name,
                                F_Id: fid + i,
                                tag: '',
                                is_cover: false,
                                photoable_type: type,
                                F_path: 'uploads/files/path/' + mytime + '/' + file.name
                            };
                        }
                    }
                }
               
                xhr = new XMLHttpRequest();
                xhr.onload = function () {
                   
                    $.modalAlert("上传成功！", "success");
                };
                xhr.onerror = function (err) {
                    console.error(err);
                    
                };
                xhr.open('post', '/SiteManage/Site/UploadPathFiles?sitename=' + mytime, true);
                xhr.send(data);
            }
            else {
                $.modalAlert("请先选择您要上传的文件！", "warning");
            }
        }

        $.modalAlert = function (content, type) {
            var icon = "";
            if (type == 'success') {
                icon = "fa-check-circle";
            }
            if (type == 'error') {
                icon = "fa-times-circle";
            }
            if (type == 'warning') {
                icon = "fa-exclamation-circle";
            }
            top.layer.alert(content, {
                icon: icon,
                title: "系统提示",
                btn: ['确认'],
                btnclass: ['btn btn-primary'],
            });
        }
    </script>
</body>
</html>
